package com.itheima.search.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.search.domain.News;
import com.itheima.search.domain.NewsVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NewsMapper extends BaseMapper<News> {

    @Select("SELECT *,t.type_name FROM tb_news n INNER JOIN tb_news_type t ON n.type_id = t.type_id")
    List<NewsVO> selectAllWithTypeName();

    @Select("SELECT *,t.type_name FROM tb_news n INNER JOIN tb_news_type t ON n.type_id = t.type_id WHERE n.news_id = #{newsId}")
    NewsVO selectOneWithTypeName(String newsId);
}